package com.example.myapplication.storage.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.myapplication.storage.entity.Book;

import java.util.Collection;
import java.util.List;

@Dao
public interface BookDao {

    @Insert
    void insert(Book book);

    @Insert
    void batchInsert(Collection<Book> books);

    @Delete
    int delete(Book book);

    @Delete
    int batchDelete(Collection<Book> books);

    @Query("delete from book")
    int deleteAll();

    @Update
    int update(Book book);

    @Update
    int batchUpdate(Collection<Book> books);

    @Query("select * from book")
    List<Book> queryAll();

    @Query("select * from book where name=:name order by id desc limit 1")
    Book queryByName(String name);
}
